Add DatetimeAttributeField, use it for datetime fields#32
Merged
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated DatetimeAttributeField for ISO-8601 timestamp attributes and migrates various resources’ created_at / expiry fields from raw strings to datetime.datetime objects, updating docs and tests accordingly.
Changes:
- Add
DatetimeAttributeFieldinresources/base.pyto deserialize ISO-8601 timestamps intodatetimeobjects. - Switch multiple resources’
created_at,expires_at, andexpire_atfields to useDatetimeAttributeField. - Update README and tests to reflect datetime-typed fields.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/resources/test_address_verification.py | Updates assertions to compare created_at as datetime objects. |
| src/didww/resources/base.py | Adds DatetimeAttributeField datetime deserialization logic. |
| src/didww/resources/address.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/address_verification.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/did.py | Migrates created_at / expires_at to DatetimeAttributeField. |
| src/didww/resources/did_reservation.py | Migrates created_at / expire_at to DatetimeAttributeField. |
| src/didww/resources/encrypted_file.py | Migrates expire_at to DatetimeAttributeField. |
| src/didww/resources/export.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/identity.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/order.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/permanent_supporting_document.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/proof.py | Migrates created_at / expires_at to DatetimeAttributeField. |
| src/didww/resources/shared_capacity_group.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/voice_in_trunk.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/voice_in_trunk_group.py | Migrates created_at to DatetimeAttributeField. |
| src/didww/resources/voice_out_trunk.py | Migrates created_at to DatetimeAttributeField. |
| README.md | Documents datetime vs date-only field behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,5 +1,6 @@ | |||
| import functools | |||
| import importlib | |||
| from datetime import datetime, timezone | |||
Comment on lines
+88
to
+95
| raw = super().__get__(instance, type) | ||
| if instance is None: | ||
| return self | ||
| if raw is None: | ||
| return None | ||
| return datetime.fromisoformat(raw.replace("Z", "+00:00")) | ||
|
|
||
|
|
Comment on lines
4
to
7
| class EncryptedFile(DidwwApiModel): | ||
| description = SafeAttributeField("description") | ||
| expire_at = SafeAttributeField("expire_at") | ||
| expire_at = DatetimeAttributeField("expire_at") | ||
|
|
0dbd0a8 to
4a75299
Compare
d7b7b60 to
18bf94e
Compare
…e types in README - Add DatetimeAttributeField, use it for all datetime fields - Remove EncryptedFile.created_at (not present in API) - Document date and datetime field types in README - Simplify date/datetime section with generic rule
18bf94e to
29bc007
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
DatetimeAttributeFieldtobase.pythat parses ISO 8601 strings todatetime.datetimeSafeAttributeFieldwithDatetimeAttributeFieldfor allcreated_at,expires_at,expire_atfields across 14 resource filescreated_atfield toEncryptedFiledatetimeobjects